﻿using System;
using System.Collections;
using System.ComponentModel;
using System.Data;
using System.Linq;
using System.Web;
using System.Web.Services;
using System.Web.Services.Protocols;
using System.Xml.Linq;
using System.Configuration;
using System.Data.OleDb;
using System.Data;
using System.Data.SqlClient;
namespace NganHang
{
    /// <summary>
    /// Summary description for Service1
    /// </summary>
    [WebService(Namespace = "http://tempuri.org/")]
    [WebServiceBinding(ConformsTo = WsiProfiles.BasicProfile1_1)]
    [ToolboxItem(false)]
    // To allow this Web Service to be called from script, using ASP.NET AJAX, uncomment the following line. 
    // [System.Web.Script.Services.ScriptService]
    public class ThanhToanService : System.Web.Services.WebService
    {

        [WebMethod]
        public string HelloWorld()
        {
            return "Hello World";
        }
        [WebMethod]
        public float ThanhToanTien(string MaTaiKhoanSrc, string MaTaiKhoanDest, float SoTien)
        {
            string sconn = ConfigurationManager.ConnectionStrings["SMOConnectionString"].ToString();
            SqlConnection conn = new SqlConnection(sconn);
            conn.Open();
            SqlCommand comm = new SqlCommand();
            /* comm.CommandText = "select count(*) as SL " +
             "from TAIKHOAN_NGANHANG where MaTaiKhoan='" + MaTaiKhoan+"' and SoTien < " + SoTien.ToString() ;
             comm.Connection = conn;
             return (int)comm.ExecuteScalar();*/
            comm.CommandText = "sp_NganHangThanhToanTien";
            comm.CommandType = CommandType.StoredProcedure;
            comm.Connection = conn;
            comm.Parameters.AddWithValue("@MaTaiKhoanSrc", MaTaiKhoanSrc);
            comm.Parameters.AddWithValue("@MaTaiKhoanDest", MaTaiKhoanDest);
            comm.Parameters.AddWithValue("@SoTien", SoTien);
            SqlParameter para = new SqlParameter("@Return", SqlDbType.Float);
            para.Direction = ParameterDirection.ReturnValue;
            comm.Parameters.Add(para);
            comm.ExecuteNonQuery();
            conn.Close();
            return float.Parse(para.Value.ToString());
            //return sconn;
        }
    }
}
